home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
asmutil
/
asm_n_z.zip
/
OWNER.ASM
< prev
next >
Wrap
Assembly Source File
|
1987-04-21
|
30KB
|
676 lines
PAGE ,132
TITLE Cluster Owner Program, Version 1.61, 21-Apr-1987
;
; Written By Steven Georgiades
;
;
; If you have any questions or comments about this or any other
; SMG program, call or write:
;
; Steven M. Georgiades
; SMG Software
; 701-H South Hayward Street
; Anaheim, CA 92804
;
CODE SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:CODE,DS:CODE,ES:CODE,SS:CODE
ORG 5CH
FCB LABEL BYTE
ORG 80H
PARAM LABEL BYTE
ORG 100H
OWNER: JMP BEGIN
DIGIT DB "0123456789ABCDEF"
PARM_ERR DB "Illegal Parameter!",7
CRLF DB 13,10,"$"
READERR DB "Error Reading Drive X:",7,13,10,"$"
SIGNON DB "Cluster Owner Program, Version 1.61",13,10
DB "SMG Software",13,10
DB "(C) Copyright 1986,1987 Steven Georgiades",13,10,10,"$"
USAGE DB "Usage:",13,10,10
DB " OWNER [d:] n [[d:] n [...]]",13,10,10
DB " d: = Optional Drive Letter",13,10
DB " n = Cluster Number to Check",13,10,10,"$"
CLUSTMSG DB "Cluster XXXXX $"
OWNERMSG DB "is Owned by $"
BADMSG DB "is Marked as Bad",13,10,"$"
FREEMSG DB "is not is Use by any File",13,10,"$"
INVALID DB "does not Exist!",7,13,10,"$"
LOSTMSG DB "Appears to be Lost!",7,13,10,"$"
RESVMSG DB "is Reserved",13,10,"$"
CLSTSEC DW ?
CLSTTOT DW ?
CLUST DW ?
DIR_LEN DW ?
DIRBUF DW ?
DIRSEC DW ?
DRIVE DB ?
EOF DW 0FF8H
FATSEC DW ?
FATSIZE DB 3
LASTDRV DB -1
RDIR_LEN DW ?
SECSIZE DW ?
STARTSEC DW ?
DIRNAME DB 14 DUP(?)
FILESPEC DB "X:\"
PATH DB "$",79 DUP(?)
FILENAME DB 14 DUP(?)
BEGIN: MOV AH,9 ; Output Sign-On Message
MOV DX,OFFSET SIGNON
INT 21H
MOV AH,19H ; Get Default Drive Number
INT 21H
MOV DRIVE,AL ; and Save
MOV SI,OFFSET PARAM ; Set up Pointer to Parameter
LODSB ; Read Parameter Length
CMP AL,2
JNB GET_PARM
MOV DX,OFFSET USAGE
JMP SHORT GET_OW03
GET_PARM: CBW
MOV BX,AX
MOV BYTE PTR [SI][BX],0 ; Terminate Parameter String
STRIP: LODSB ; Strip Off Leading Whitespace
CMP AL,' '
JE STRIP
CMP AL,9
JE STRIP
OR AL,AL ; If End-of-Parameter,
JZ EXIT ; Continue Proccessing
CMP BYTE PTR [SI],':' ; If Drive Letter,
JNE NOTDRIVE
AND AL,0DFH ; Convert to Drive Number
SUB AL,'A'
MOV DRIVE,AL ; and Save
LODSB ; Skip Colon
JMP SHORT STRIP ; Continue
NOTDRIVE: DEC SI ; ReUse Last Character
CALL GET_WORD ; Read Cluster Number (Hex)
JNE PARM_OK ; If Error,
PARMERR: MOV DX,OFFSET PARM_ERR ; Output Parameter Error
MOV AH,9
INT 21H
MOV AX,4C01H ; Exit to DOS
INT 21H
PARM_OK: MOV CLUST,DX ; Save Cluster Number
CALL GET_OWNR ; Find Cluster Owner
JMP SHORT STRIP ; Get Next Parameter
EXIT: MOV AX,4C00H ; Exit to DOS
INT 21H
GET_OWNR: PUSH AX ; Save Registers
PUSH BX
PUSH CX
PUSH DX
PUSH DI
PUSH SI
MOV PATH,'$' ; Initialize Path
MOV AL,DRIVE ; If drive has changed,
CMP AL,LASTDRV
JNE GET_OW01
JMP GET_OW07
GET_OW01: MOV LASTDRV,AL ; Last Drive = This Drive
MOV CX,1 ; Read Boot Record
MOV DX,0
MOV BX,OFFSET FATBUF
INT 25H
JNC GET_OW04 ; If Error,
GET_OW02: POPF
MOV AL,DRIVE ; Convert Drive Number
ADD AL,'A'
MOV READERR[20],AL
MOV DX,OFFSET READERR ; Point to Read Error
GET_OW03: MOV AH,9 ; Output Error Message
INT 21H
MOV AX,4C01H ; Exit to DOS
INT 21H
GET_OW04: POPF
MOV AX,FATBUF[11] ; Read Sector Size
MOV SECSIZE,AX ; and Save
MOV AL,BYTE PTR FATBUF[13] ; Read Sectors per Cluster
XOR AH,AH
MOV CLSTSEC,AX ; and Save
MOV CX,FATBUF[14] ; Read # of Reserved Sectors
MOV AL,BYTE PTR FATBUF[16] ; Read # of FAT's
XOR AH,AH ; Convert to Word
MOV BX,FATBUF[22] ; Read Sectors per FAT
MOV FATSEC,BX
MUL BX ; Calculate Total FAT Sectors
ADD CX,AX ; Add to Reserved Sectors
MOV AX,FATBUF[17] ; Read Number of DIR Entries
MOV RDIR_LEN,AX
PUSH CX ; Calculate DIR Sectors
MOV CL,5
SHL AX,CL
POP CX
MOV BX,SECSIZE
XOR DX,DX
DIV BX
OR DX,DX ; Adjust for Partial Sector
JZ GET_OW05
INC AX
GET_OW05: MOV DIRSEC,AX ; Save DIR Sectors
ADD CX,AX ; Add DIR Sectors to Reserved
MOV STARTSEC,CX ; Save in STARTSEC
MOV AX,FATSEC ; Determine FAT Buffer Size
MOV BX,SECSIZE
MUL BX
ADD AX,OFFSET FATBUF
MOV DIRBUF,AX ; Save DIRBUF Pointer
MOV AX,FATBUF[19] ; Read Total Sectors on Media
SUB AX,CX ; Calc. Total Data Clusters
MOV BX,CLSTSEC
XOR DX,DX
DIV BX
ADD AX,2
MOV CLSTTOT,AX ; and Save
CMP AX,4081 ; Adjust FAT Size
JLE GET_OW06
MOV FATSIZE,4
MOV EOF,0FFF8H
JMP SHORT GET_OW07
GET_OW06: MOV FATSIZE,3
MOV EOF,0FF8H
GET_OW07: MOV AL,DRIVE ; Read FAT
MOV CX,FATSEC
MOV DX,1
MOV BX,OFFSET FATBUF
INT 25H
JNC GET_OW08
JMP GET_OW02 ; If Error, Say So
GET_OW08: POPF
MOV BX,CLUST ; Get Cluster Number
MOV AX,BX ; Convert Cluster # to Decimal
MOV DI,OFFSET CLUSTMSG[13]
CALL DEC5OUT
CALL STRIP0 ; Strip Off Leading Zeroes
MOV AH,9
MOV DX,OFFSET CLUSTMSG ; Output Cluster Message
INT 21H
CMP